package com.itheima.Demo01.demo01;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class Test05 {
    public static void main(String[] args) {
        HashMap<String,Integer> map = new HashMap<>();
        File file = new File("D:\\soft\\day0610-code");
        getmethod(map,file);
        for (Map.Entry<String, Integer> stringIntegerEntry : map.entrySet()) {
            System.out.println(stringIntegerEntry.getKey()+"--"+stringIntegerEntry.getValue());
        }

    }

    private static void getmethod(HashMap<String,Integer> map, File file) {
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()){
                String name = file1.getName();
                String[] split = name.split("\\.");
                String s = split[split.length - 1];
                map.put(s,map.containsKey(s)?map.get(s)+1:1);
            }else {
                getmethod(map, file1);
            }
        }
    }
}
